package com.wstx.mediaserver.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.ParserConfig;
import com.wstx.mediaserver.domain.dto.RawVideoInfo;
import com.wstx.mediaserver.service.RecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//流媒体录制相关业务
@RestController
@RequestMapping("/record")
@RequiredArgsConstructor
public class RecordController {

    final RecordService service;

    //视频录制回调信息接收与转发
    @PostMapping("/callback")
    public void callbackReceive(@RequestBody String rawInfo) {
        RawVideoInfo rawVideoInfo = JSON.parseObject(rawInfo, RawVideoInfo.class, Feature.IgnoreNotMatch);
        service.handleCallback(rawVideoInfo);
    }
}
